@section('title') 我的订单 @parent @stop
@section('content')

<div class="container">
	<img alt="模式二扫码支付" src="http://paysdk.weixin.qq.com/example/qrcode.php?data=<?php echo urlencode($data['url']);?>" style="width:150px;height:150px;"/>
	<div class="sum"></div>
</div>
<script type="text/javascript">
	var jumpUrl = "<?php echo Config::get('app.url'); ?>";
	var outTradeNo = "<?php echo $data['out_trade_no']; ?>";
</script>
<script>
	var t1;
	var sum =0;
	$(document).ready(function(){
		
		function update_notify(){
			sum++;
			if(sum>600){window.clearInterval(t1);return false;}
			if(sum>180){
				m = sum%10;
				if(m!=0){return false;}
			}
			$(".sum").html(sum);

			var payment_query_url = jumpUrl + '/payment/query/'+outTradeNo;
		    $.get(payment_query_url, function(data){
		          
	        }, "json").error(function(data) {
                var status_code = $.parseJSON(data.responseText);
                layer.msg(status_code.message);
	        }).success(function(data) {
				console.log(data);
	            var obj = data.data;
// 	            if(obj.trade_state=='NOTPAY') {$(".buttom").html('微信扫描成功请在手机上确认支付');}
	            if(obj.trade_state=='SUCCESS') {
		            window.location.href = jumpUrl + '/payment/success/'+outTradeNo;
		        }
	        });
		}
		t1 = window.setInterval(update_notify,1000);

		window.onblur = function(){
			clearInterval(t1);
		}

		window.onfocus = function(){
			t1 = setInterval(function(){
				update_notify();
			},1000 );
		}
		
});

</script>
@stop